package fina2.dcs.fis;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List;

import javax.ejb.Remove;
import javax.ejb.Stateful;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import org.jboss.annotation.ejb.LocalBinding;
import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.AutoCreate;
import org.jboss.seam.annotations.Destroy;
import org.jboss.seam.annotations.Logger;
import org.jboss.seam.annotations.Scope;
import org.jboss.seam.log.Log;

@Stateful
@LocalBinding(jndiBinding = "LicenceSession/local")
@Scope(ScopeType.SESSION)
@SuppressWarnings("unchecked")
@AutoCreate
public class LicenceSession implements LicenceLocal,Serializable {

	@PersistenceContext
	private EntityManager em;
	
	@Logger
	private Log log;

	public List<Licence> findByBankId(BigDecimal bankId) {
		List<Licence> lic = null;
		try {
			lic = em.createQuery("FROM " + Licence.class.getName() + " l WHERE l.bankId IN(" + bankId + ")").getResultList();
		} catch (Exception ex) {
			log.error(ex.getMessage(), ex);
		}
		return lic;
	}

	@Remove
	@Destroy
	public void remove() {

	}

}
